package model;

public class LogPanelData {
	private ProxyEvent event;
	private String[] text;
	private String place = "Tutti";
	private String log;

	public LogPanelData(ProxyEvent event) {
		this.event = event;
	}

	public String genText() {

		this.place = event.getFilter();

		text = new String[event.getEvents().size()];

		if (place.equalsIgnoreCase("Tutti")) {

			for (int i = 0; i < event.getEvents().size(); i++) {

				text[i] = (event.getEvents().get(i) + " "
						+ event.getDates().get(i) + " "
						+ event.getPlaces().get(i) + "\n");

			}

			log = new String();

		} else {
			for (int i = 0; i < event.getEvents().size(); i++) {
				if (place.equalsIgnoreCase(event.getPlaces().get(i))) {

					text[i] = (event.getEvents().get(i) + " "
							+ event.getDates().get(i) + " "
							+ event.getPlaces().get(i) + "\n");

				}
			}

			log = new String();
		}

		for (int j = 0; j < text.length; j++) {
			if (text[j] == null) {
				text[j] = " ";
			}
			log = (log + text[j]);
		}
		return log;
	}

}